﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style TargetType="TabItem" x:Key="TabContainer">
        <Setter Property="Foreground" Value="White" />
        <Setter Property="FontFamily" Value="Segoe UI" />
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">

                    <Border Background="#565454"
                                BorderBrush="LightGray"
                                BorderThickness="1,1,1,1"
                                x:Name="Border"
                                Height="30"
                                MinWidth="100"
                            Margin="0,0,5,0">
                        <Grid>
                            <ContentPresenter Name="TheHeaderContentPresenter"
                                              ContentSource="Header"
                                              HorizontalAlignment="Center" 
                                              VerticalAlignment="Center"
                                              Margin="10,0,10,0"/>
                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Trigger.Setters>
                                <Setter TargetName="Border" Property="Background" Value="{StaticResource DefaultBackgroundBrush}"/>
                                <Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,0"/>
                                <Setter Property="Panel.ZIndex" Value="1"/>
                            </Trigger.Setters>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>
    

    <Style TargetType="{x:Type TabControl}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Background" Value="#565454" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="BorderBrush" Value="White" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource TabContainer}" />
        <Setter Property="TabStripPlacement" Value="Top" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabControl">
                    <Grid KeyboardNavigation.TabNavigation="Local">
                        <Grid.RowDefinitions>
                            <RowDefinition Name="TopRow" />
                            <RowDefinition Name="BottomRow" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Name="LeftColumn" />
                            <ColumnDefinition Name="RightColumn" />
                        </Grid.ColumnDefinitions>

                        <TabPanel Name="TabPanelBorder"
                                  Grid.Row="0"
                                  Height="30"
                                  Margin="0,0,0,-1"
                                  Panel.ZIndex="1"
                                  Background="Transparent"
                                  ClipToBounds="False"
                                  IsItemsHost="True"
                                  KeyboardNavigation.TabIndex="1" />

                        <Border x:Name="brdOuterTabPanel"
                                Background="{StaticResource DefaultBackgroundBrush}"
                                BorderBrush="White"
                                BorderThickness="1">
                            <!--  This is the first/outer Border drawn on the TabPage  -->

                            <!--
                                This is where the Content of the selected TabPage
                                will be rendered.
                            -->
                            <Grid>
                                <ContentPresenter x:Name="PART_SelectedContentHost"
                                                  ContentSource="SelectedContent"/>
                                <TextBlock Name="PART_TextBlock"
                                           HorizontalAlignment="Center"
                                           IsEnabled="False"
                                           Text="No data."
                                           VerticalAlignment="Center"
                                           Visibility="Collapsed" />
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="{x:Static Dock.Top}">
                            <Setter TargetName="TabPanelBorder" Property="Height" Value="30" />

                            <Setter TargetName="TopRow" Property="Height" Value="Auto" />
                            <Setter TargetName="BottomRow" Property="Height" Value="*" />
                            <Setter TargetName="LeftColumn" Property="Width" Value="Auto" />
                            <Setter TargetName="RightColumn" Property="Width" Value="*" />

                            <Setter TargetName="TabPanelBorder" Property="Grid.Row" Value="0" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.RowSpan" Value="1" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.Column" Value="0" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.ColumnSpan" Value="2" />

                            <Setter TargetName="brdOuterTabPanel" Property="Grid.Row" Value="1" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.RowSpan" Value="1" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.Column" Value="0" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.ColumnSpan" Value="2" />

                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="{x:Static Dock.Bottom}">
                            <Setter TargetName="TabPanelBorder" Property="Height" Value="30" />

                            <Setter TargetName="TopRow" Property="Height" Value="*" />
                            <Setter TargetName="BottomRow" Property="Height" Value="Auto" />
                            <Setter TargetName="LeftColumn" Property="Width" Value="Auto" />
                            <Setter TargetName="RightColumn" Property="Width" Value="*" />

                            <Setter TargetName="TabPanelBorder" Property="Grid.Row" Value="1" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.RowSpan" Value="1" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.Column" Value="0" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.ColumnSpan" Value="2" />

                            <Setter TargetName="brdOuterTabPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.RowSpan" Value="1" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.Column" Value="0" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.ColumnSpan" Value="2" />

                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="{x:Static Dock.Left}">
                            <Setter TargetName="TabPanelBorder" Property="Width" Value="30" />

                            <Setter TargetName="TopRow" Property="Height" Value="*" />
                            <Setter TargetName="BottomRow" Property="Height" Value="Auto" />
                            <Setter TargetName="LeftColumn" Property="Width" Value="Auto" />
                            <Setter TargetName="RightColumn" Property="Width" Value="*" />

                            <Setter TargetName="TabPanelBorder" Property="Grid.Row" Value="0" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.RowSpan" Value="2" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.Column" Value="0" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.ColumnSpan" Value="1" />

                            <Setter TargetName="brdOuterTabPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.RowSpan" Value="2" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.Column" Value="1" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.ColumnSpan" Value="1" />

                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="{x:Static Dock.Right}">
                            <Setter TargetName="TabPanelBorder" Property="Width" Value="30" />

                            <Setter TargetName="TopRow" Property="Height" Value="*" />
                            <Setter TargetName="BottomRow" Property="Height" Value="Auto" />
                            <Setter TargetName="LeftColumn" Property="Width" Value="*" />
                            <Setter TargetName="RightColumn" Property="Width" Value="Auto" />

                            <Setter TargetName="TabPanelBorder" Property="Grid.Row" Value="0" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.RowSpan" Value="2" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.Column" Value="1" />
                            <Setter TargetName="TabPanelBorder" Property="Grid.ColumnSpan" Value="1" />

                            <Setter TargetName="brdOuterTabPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.RowSpan" Value="2" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.Column" Value="0" />
                            <Setter TargetName="brdOuterTabPanel" Property="Grid.ColumnSpan" Value="1" />

                        </Trigger>
                        <Trigger Property="SelectedContent" Value="{x:Null}">
                            <Setter TargetName="PART_TextBlock" Property="Visibility" Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="HasItems" Value="False">
                <Setter Property="Visibility" Value="Collapsed" />
            </Trigger>
        </Style.Triggers>
    </Style>


</ResourceDictionary>